class Animal{
    public String name;
    public int age;
    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
    }
    public void eat(){
        System.out.println(this.name + "吃");
    }
 }

 class Dog extends Animal{
     public Dog(String name, int age) {
         super(name, age);
     }
     public void eat(){
         System.out.println(this.name + "吃狗粮");
     }

 }
 class Cat extends Animal{
    public Cat(String name,int age){
        super(name,age);
    }
    public void eat(){
        System.out.println(this.name+"吃猫粮");
    }
 }

public class Test1 {
//方法传参：形参为父类型引用，可以接收任意子类的对象
    public static void func(Animal a){
        a.eat();
    }
//返回值：返回任意子类对象

    public static void main(String[] args) {
    func(new Dog("白糖",10));
    func(new Cat("大飞",11));
    }
}